import java.util.Stack;
//用栈实现最小栈
public class Solution {
    Stack<Integer> s1=new Stack<>();
    Stack<Integer> minstack=new Stack<>();
    public void push(int node) {
       s1.push(node);
       if(minstack.empty()){
           minstack.push(node);
       }else{
       int val=minstack.peek();
       if(node<=val){
           minstack.push(node);
             }
       } 
    }
    public void pop() {
      if(!s1.empty()){
          int x=s1.pop();
          if(x==minstack.peek()){
              minstack.pop();
          }
      }
    }
    public int top() {
        if(!s1.empty()){
            return s1.peek();
        }
        return -1;
    }
    
    public int min() {
        if(!minstack.empty()){
            return minstack.peek();
        }  
        return -1;
    }
}
